<%@ page language="java" pageEncoding="UTF-8" contentType="text/html; charset=utf-8" errorPage="/error.jsp" isELIgnored="false" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-logic" prefix="logic" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-tiles" prefix="tiles" %>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jstl/fmt" prefix="fmt" %>
<%@ taglib uri="http://www.opensymphony.com/oscache" prefix="cache" %>
<%@ taglib uri="http://atleap.blandware.com/taglib" prefix="atleap" %>
<html:xhtml />

<atleap:constants className="org.apache.struts.Globals" var="LOCALE_KEY" />
<atleap:constants className="com.blandware.atleap.webapp.util.questionnaire.QuestionnaireModuleWebConstants" var="QUESTIONNAIRES_TO_FILL_GRID" />
<atleap:constants className="com.blandware.atleap.webapp.util.core.WebappConstants" var="GRID_PAGE_SIZE" />
<atleap:globalProperty name="${pageScope.GRID_PAGE_SIZE}" defaultValue="10" type="integer" var="pageSize" />

<atleap:content identifier="information" ignore="true" />

<c:set var="infoCells" value="1" />
<c:set var="constantButtonCells" value="0" />
<c:set var="additionalCells" value="0" />

<atleap:message key="questionnaire.questionnaire.buttons.fill" var="fillMsg"/>
<atleap:grid name="${pageScope.QUESTIONNAIRES_TO_FILL_GRID}" pageSize="${pageSize}">
	<atleap:messages property="questionnaireNotFound" />
    <atleap:messages property="ownerNotFound" />
    <atleap:messages property="preparationFailed" />
	<atleap:messages property="success" />
    <atleap:queryParameter name="localeIdentifier" value="${sessionScope[pageScope.LOCALE_KEY].language}" />
    <atleap:queryParameter name="activeOnly" value="${true}" />
    <table border="0" cellpadding="0" cellspacing="0" class="grid">
        <thead>
            <tr>
                <th nowrap="nowrap">
                    <atleap:column fieldName="title.simpleValue" fieldKey="questionnaire.questionnaire.form.title">
                        <atleap:sort>
                            <atleap:message key="${fieldKey}" />
                            <atleap:sortAsc>
                                <img border="0" src="<atleap:rewriteUrl href="/images/theme/${appConfig['frontendCssTheme']}/grid/ascSort.gif" />"  />
                            </atleap:sortAsc>
                            <atleap:sortDesc>
                                <img border="0" src="<atleap:rewriteUrl href="/images/theme/${appConfig['frontendCssTheme']}/grid/descSort.gif" />"  />
                            </atleap:sortDesc>
                        </atleap:sort>
						<atleap:stringFilter>
							<atleap:filterEnabled>
								<img border="0" src="<atleap:rewriteUrl href="/images/theme/${appConfig['frontendCssTheme']}/grid/filterEnabled.gif" />"  />
							</atleap:filterEnabled>
							<atleap:filterDisabled>
								<img border="0" src="<atleap:rewriteUrl href="/images/theme/${appConfig['frontendCssTheme']}/grid/filterDisabled.gif" />"  />
							</atleap:filterDisabled>
						 </atleap:stringFilter>
                    </atleap:column>
                </th>
                <c:if test="${constantButtonCells + additionalCells > 0}">
                    <th colspan="${constantButtonCells + additionalCells}">
                        <img src="<atleap:rewriteUrl href="/images/theme/${appConfig['frontendCssTheme']}/spacer.gif" />" border="0"  />
                    </th>
                </c:if>
            </tr>
        </thead>
        <tbody>
            <atleap:contextMenu var="menuId">
                <atleap:rowsIterator var="questionnaire" beanId="questionnaireManager" method="listQuestionnaires" oddClass="oddRow" evenClass="evenRow">
                    <atleap:itemSet>
                        <atleap:rewriteUrl action="${questionnaire.uri}" var="defaultUrl" />
                        <c:set var="onTrClickCode" value="dispatchGridTrClick(event, this, &#039;${defaultUrl}&#039;);" />
                        <c:set var="tdClass" value="pointerCursorCell" />
                        <tr class="${rowClass}" onclick="${onTrClickCode}">
                            <td class="${tdClass}">
                                <atleap:link href="${defaultUrl}" title="${fillMsg}">
                                    <atleap:fieldValue valueMap="${questionnaire.title}" />
                                </atleap:link>
                            </td>
                        </tr>
                    </atleap:itemSet>
                </atleap:rowsIterator>
            </atleap:contextMenu>
            <atleap:noRows>
                <tr>
                    <td class="tfoot"  colspan="${infoCells + constantButtonCells + additionalCells}" align="center">
                        <em><atleap:message key="core.commons.nothingToShow"/></em>
                    </td>
                </tr>
            </atleap:noRows>
        </tbody>
        <tfoot>
            <tr>
                <atleap:pager pageCount="10">
                    <td  colspan="${infoCells + constantButtonCells + additionalCells}" align="center">
                        <atleap:message key="core.grid.pager.title" />&nbsp;
                        <atleap:firstPage><img src="<atleap:rewriteUrl href="/images/theme/${appConfig['frontendCssTheme']}/first.gif" />" border="0" alt="<atleap:message key="core.grid.pager.first"/>" title="<atleap:message key="core.grid.pager.first"/>" /></atleap:firstPage>
                        <atleap:prevPage><img src="<atleap:rewriteUrl href="/images/theme/${appConfig['frontendCssTheme']}/prev.gif" />" border="0" alt="<atleap:message key="core.grid.pager.prev"/>" title="<atleap:message key="core.grid.pager.prev"/>" /></atleap:prevPage>
                        <atleap:pagesIterator>
                            <atleap:page>${pageNumber}&nbsp;</atleap:page>
                            <atleap:currentPage><b>${pageNumber}</b>&nbsp;</atleap:currentPage>
                        </atleap:pagesIterator>
                        <atleap:nextPage><img src="<atleap:rewriteUrl href="/images/theme/${appConfig['frontendCssTheme']}/next.gif" />" border="0" alt="<atleap:message key="core.grid.pager.next"/>" title="<atleap:message key="core.grid.pager.next"/>" /></atleap:nextPage>
                        <atleap:lastPage><img src="<atleap:rewriteUrl href="/images/theme/${appConfig['frontendCssTheme']}/last.gif" />" border="0" alt="<atleap:message key="core.grid.pager.last"/>" title="<atleap:message key="core.grid.pager.last"/>" /></atleap:lastPage>
                    </td>
                </atleap:pager>
            </tr>
        </tfoot>
    </table>
</atleap:grid>
